// Replication package -----------------------------------------------------

clear all
set varabbrev on
cls


// DIRECTORIES -------------------------------------------------------------

* Adjust the "main" path to the replication package folder in your local machine
*global main "$path_for_replication_folder" 

foreach path in raw proc data code results gis code {
	global `path' "$main/`path'"
}

adopath + "$main/ado"
cd "$main"

ssc install shp2dta		, replace
ssc install spmap		, replace
ssc install geonear		, replace
ssc install outreg2		, replace
ssc install regsave		, replace
ssc install texsave		, replace
ssc install palettes	, replace
ssc install colrspace	, replace
ssc install binscatter	, replace
ssc install estout		, replace


// PRELIMINARIES -------------------------------------------------------------
// Control which scripts run

local figure_1a              = 1
local figure_1               = 1
local figure_2               = 1
local table_1                = 1
local table_2                = 1
local table_3                = 1
local figure_A1              = 1
local figure_A2              = 1
local figure_A3_A4           = 1
local figure_C1              = 1
local figure_C2              = 1
local table_C2               = 1
local table_C5_district_crop = 1
local table_C5_subdistrict   = 1


**************************************************************************
*                               Main Paper                               * 
**************************************************************************
* Figure I: 
** Figure I(a)
if (`figure_1a' == 1) {
	di "Running R script for figure 1a..."
	
	local rscript_path "/usr/local/bin/Rscript"  // Adjust this path as necessary
	local rscript "$code/figure_1a.r"
	
	di "Rscript path: `rscript_path'"
    di "R script path: `rscript'"
	
	shell "`rscript_path'" "`rscript'" 
	}


** Figure I(b), I(c), I(d)
if (`figure_1' == 1) do "$code/figure_1.do"

* Figure II: event study figures
if (`figure_2' == 1) do "$code/figure_2.do"

* Table I: Summary statistics
if (`table_1' == 1) do "$code/table_1.do"

* Table II: Balance table
if (`table_2' == 1) do "$code/table_2.do"


* Table III (main panel), 
if (`table_3' == 1) do "$code/table_3.do"


***************************************************************************
*                                 Appendix                                * 
***************************************************************************

* Appendix Figure A1: Data validation: HYV adoption
if (`figure_A1' == 1) do "$code/figure_A1.do"

* Appendix Figure A2: Data validation: share of igrrigated area
if (`figure_A2' == 1) do "$code/figure_A2.do"


* Appendix FigureA3: Correlation btw. different productity measures (district) and A4 (cell)
if (`figure_A3_A4' == 1) do "$code/figure_A3_A4.do"


* Appendix Figure C1: Calls to Kisan Call Centers
if (`figure_C1' == 1) do "$code/figure_C1.do"


* Appendix Figure C2: the share of non-state language speakers
if (`figure_C2' == 1) do "$code/figure_C2.do"


* Appendix Table C2: robustness table with alternative distance bandwidths
if (`table_C2' == 1) do "$code/table_C2.do"


* Appendix Table C5
** Panel A: district-crop analysis
if (`table_C5_district_crop' == 1) do "$code/table_C5_district_crop.do"


** Panel B: subdistrict level analysis
if (`table_C5_subdistrict' == 1) do "$code/table_C5_subdistrict.do"





